<?php

namespace app\admin\model\vppz;

use think\Model;
use think\Db;
use traits\model\SoftDelete;

class VipPackage extends Model
{

    use SoftDelete;



    // 表名
    protected $name = 'vppz_vip_package';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
    protected $append = [
        'duration_text',
        'price_text',
        'old_price_text'
    ];
    	public function getDurationTextAttr($value,$data)
    {
        return $data['duration'].'个月';
    }
    	public function getPriceTextAttr($value,$data)
    {
        return '￥'.$data['price'];
    }
    	public function getOldPriceTextAttr($value,$data)
    {
        return '￥'.$data['originalPrice'];
    }

public function VipChannel()
    {
        return $this->belongsTo('VipChannel', 'channel', 'key', [], 'LEFT')->setEagerlyType(0);
    }
}
